 package com.oanda.blackberry.restapi;
 
 import java.util.Vector;
 
 public class OrderListResponse
 {
   int id;
   String type;
   String symbol;
   int units;
   long time;
   double price;
   double stopLoss;
   double takeProfit;
   long expirity;
   double highLimit;
   double lowLimit;
   double trailingStop;
 
   public OrderListResponse(int id, String type, String symbol, int units, long time, double price, double stopLoss, double takeProfit, long expirity, double highLimit, double lowLimit, double trailingStop)
   {
     this.id = id;
     this.type = type;
     this.symbol = symbol;
     this.units = units;
     this.time = time;
     this.price = price;
     this.stopLoss = stopLoss;
     this.takeProfit = takeProfit;
     this.expirity = expirity;
     this.highLimit = highLimit;
     this.lowLimit = lowLimit;
     this.trailingStop = trailingStop;
   }
 
   public long getExpirity() {
     return this.expirity;
   }
 
   public double getHighLimit() {
     return this.highLimit;
   }
 
   public int getId() {
     return this.id;
   }
 
   public double getLowLimit() {
     return this.lowLimit;
   }
 
   public double getPrice() {
     return this.price;
   }
 
   public double getStopLoss() {
     return this.stopLoss;
   }
 
   public String getSymbol() {
     return this.symbol;
   }
 
   public double getTakeProfit() {
     return this.takeProfit;
   }
 
   public long getTime() {
     return this.time;
   }
 
   public double getTrailingStop() {
     return this.trailingStop;
   }
 
   public String getType() {
     return this.type;
   }
 
   public int getUnits() {
     return this.units;
   }
 
   public static void sort(OrderListResponse[] r)
   {
     alphaSort(r);
   }
 
   public static void bubbleSort(OrderListResponse[] arr)
   {
     boolean swapped = true;
     int j = 0;
 
     while (swapped) {
       swapped = false;
       j++;
       for (int i = 0; i < arr.length - j; i++)
         if (arr[i].getId() > arr[(i + 1)].getId()) {
           OrderListResponse tmp = arr[i];
           arr[i] = arr[(i + 1)];
           arr[(i + 1)] = tmp;
           swapped = true;
         }
     }
   }
 
   public static void alphaSort(OrderListResponse[] arr)
   {
     Vector sorted = new Vector();
 
     sorted.addElement(arr[0]);
     for (int i = 1; i < arr.length; i++)
     {
       for (int j = 0; j < i; j++)
       {
         if (((OrderListResponse)sorted.elementAt(j)).getSymbol().compareTo(arr[i].getSymbol()) > 0)
         {
           sorted.insertElementAt(arr[i], j);
           break;
         }
         if (j != i - 1)
           continue;
         sorted.addElement(arr[i]);
         break;
       }
     }
 
     for (int i = 0; i < arr.length; i++)
     {
       arr[i] = ((OrderListResponse)sorted.elementAt(i));
     }
   }
 
   public static void bubbleSort(int[] arr)
   {
     boolean swapped = true;
     int j = 0;
 
     while (swapped) {
       swapped = false;
       j++;
       for (int i = 0; i < arr.length - j; i++)
         if (arr[i] > arr[(i + 1)]) {
           int tmp = arr[i];
           arr[i] = arr[(i + 1)];
           arr[(i + 1)] = tmp;
           swapped = true;
         }
     }
   }
}

